#include <stdio.h>
#include "list.h"
#include "../mem/fix_obj_pool/fix_obj_pool.h"

int main()
{
	struct fix_obj_pool *obj_pool = list_create_obj_pool(sizeof(int),4096,0);
	list_t l = list_create(sizeof(int),obj_pool);
	LIST_PUSH_BACK(int,l,1);
	LIST_PUSH_BACK(int,l,2);
	LIST_PUSH_BACK(int,l,3);
	LIST_PUSH_BACK(int,l,4);
	list_iter it = LIST_FIND(int,l,2);
	LIST_INSERT_BEFORE(int,l,it,5);
	LIST_INSERT_AFTER(int,l,it,6);
	it = list_begin(l);
	list_iter end = list_end(l);
	
	for( ; !iter_is_equal(it,end); )
	{
		if(ITER_GET_VAL(int,it) == 3)
			it = list_erase(l,it);
		else
			it = iter_next(it);
	}
	
	it = list_begin(l);
	while(!iter_is_equal(it,end))
	{
		printf("%d\n",ITER_GET_VAL(int,it));
		it = iter_next(it);
	}
	
	printf("free size:%d\n",get_free_size(obj_pool));
	
	list_destroy(&l);
	printf("free size:%d\n",get_free_size(obj_pool));
	destroy_pool(&obj_pool);
   
	return 0;
}